<!--/**
* @author xuyh0817
* @email xuyh0817@foxmail.com
* @date 2022-02-16 15:58
* @version 2.0.0
* @doc todo
* @website todo
* @remark  如果要分发源码，需在本文件顶部保留此文件头信息！！
*/
-->
<template>
  <div :style="style">
    <!--    <template v-if="Object.keys(slots).length !== 0">-->
    <!--&lt;!&ndash;      <extend-slot v-for="(render, key) of slots" v-slot:[key] :key="key" :data="slotData" :render="render"/>&ndash;&gt;-->
    <!--    </template>-->
    <div v-html="value"></div>
  </div>
</template>

<script>

import ComponentMixin from '../../XRenderMixins/XRenderComponentMixin'
import {COMPONENT_TYPE} from '../../constants'

export default {
  name: COMPONENT_TYPE.HTML,
  mixins: [ComponentMixin],
  props: {
    value: {
      type: [String, Number, Object, Array]
    }
  },
  computed: {
    style: {
      get() {
        const {attrs, isDebug, formItem} = this
        const {style} = attrs
        if (typeof (style) !== 'object' && typeof (style) !== 'string') {
          isDebug ? console.warn(`${formItem.prop} style类型错误,非String或Object`) : ''
          return {}
        }
        if (typeof (style) === 'object') {
          return style || {}
        }
        return (new Function('return ' + style))()
      }
    }
  }
}
</script>

<style scoped lang="css">
</style>
